<template>
	<view class="u-flex">
		<view v-if="isOther && !useState.inMyList" class="btn-box u-flex u-row-around">
			<button class="btn-item" @click="leftCilckBtn"
				style="color:rgba(43, 173, 253, 1);background-color: #FFFFFF;border: 1rpx solid rgba(43, 173, 253, 1);box-sizing: border-box;">
				<image style="width: 40rpx;height: 40rpx;margin-right: 12rpx;"
					src="https://job.ydylmold.cn/mingpian/image/comIndex/phone-btn.png" mode="widthFix"></image> 极速联系
			</button>
			<button class="btn-item"
				:style="useState.isApply?'background-color: #666;':'background-color: rgba(43, 173, 253, 1);'"
				style="color: #FFFDEF;" @click="$u.throttle(rightCilckBtn, 3000)">
				<image style="width: 40rpx;height: 40rpx;margin-right: 12rpx;"
					src="https://job.ydylmold.cn/mingpian/image/comIndex/peo-btn.png" mode="widthFix"></image>
				{{useState.isMyFriend?'发消息':(useState.isApply?'申请中':'添加至通讯录')}}
			</button>
		</view>
		<view v-if="isOther && useState.inMyList" class="btn-box u-flex u-row-around">
			<button class="btn-item" @click="$store.dispatch('usrBlackListRemove', useNum)"
				style="color:rgba(43, 173, 253, 1);background-color: #FFFFFF;border: 1rpx solid rgba(43, 173, 253, 1);box-sizing: border-box;">
				<image style="width: 40rpx;height: 40rpx;margin-right: 12rpx;"
					src="https://job.ydylmold.cn/mingpian/image/comIndex/phone-btn.png" mode="widthFix"></image> 移出黑名单
			</button>
			<button class="btn-item" style="color: #FFFDEF;background-color: rgba(220, 0, 0, 1);"
				@click="$store.dispatch('delFriends', useNum)">
				<image style="width: 40rpx;height: 40rpx;margin-right: 12rpx;"
					src="https://job.ydylmold.cn/mingpian/image/comIndex/peo-btn.png" mode="widthFix"></image> 删除好友
			</button>
		</view>
	</view>
</template>
<script>
	import {
		mapGetters
	} from 'vuex'
	import {
		addFriend,
		callPeople
	} from '@/utils/common.js'
	import {
		userVipSearch
	} from '@/common/api/pay.js'
	import {
		updAddFriends
	} from '@/common/api/msg.js'
	import {getToken} from '@/utils/token.js'
	export default {
		props: ['isOther', 'useNum', 'acPhone', 'isShare'],
		computed: {
			...mapGetters(['useState', 'stateList']),
		},
		created: function() {
			//console.log(this.isOther, this.useNum, this.acPhone, this.isShare)
		},
		methods: {
			leftCilckBtn() {
				//console.log("this.useNum", this.useNum);
				this.$store.dispatch('toAddPeople',{
					useNum:this.useNum,
					setType:1
				}).then(res=>{
				//console.log("res", res);
					if(res){
						callPeople(this.useNum)
					}
				})
			},
			async rightCilckBtn() {
				if (this.useState.isMyFriend) {
					uni.navigateTo({
						url: `/pages/comment/chat/index?useNum=${this.useNum}`
					});
					return;
				}
				this.$store.dispatch('toAddPeople',{
					useNum:this.useNum,
					setType:3,
					isApply:this.useState.isApply
				}).then(res=>{
					if(res){
						addFriend(this.useNum).then(isAdd=>{
							if(isAdd){
								this.$store.commit('setUseState', {
									key: 'isApply',
									obj: true
								})
								this.$u.toast('申请成功')
							}else{
								this.$store.commit('setUseState', {
									key: 'isApply',
									obj: false
								})
								this.$u.toast('申请失败')
							}
						})
					}
				})
			},
		}
	}
</script>
<style scoped lang="scss">
	.btn-box {
		background-color: #FFFFFF;
		padding: 12rpx 22rpx 20rpx 22rpx;
		width: 750rpx;
		position: fixed;
		bottom: 0;
		left: 0;
		z-index: 99;

		.btn-item {
			font-size: 30rpx;
			line-height: 82rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			margin: 0;
			padding: 0;
			flex: 1;
			margin: 0 10rpx;
			border-radius: 42rpx;
		}
	}
</style>
